/*
 * This file is part of TradeHelper library.
 *
 * TradeHelper library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TradeHelper library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TradeHelper library.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.rag.core;

import com.thoughtworks.xstream.annotations.XStreamAlias;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: mgarin Date: 04.04.12 Time: 17:14
 */

@XStreamAlias( "ItemClass" )
public enum ItemClass
{
    // Weapon classes
    dagger,
    oneHandedSword,
    twoHandedSword,
    oneHandedSpear,
    twoHandedSpear,
    oneHandedAxe,
    twoHandedAxe,
    mace,
    oneHandedStaff,
    twoHandedStaff,
    bow,
    knuckle,
    musicalInstrument,
    whip,
    book,
    katar,
    revolver,
    rifle,
    gatlingGun,
    shotgun,
    grenadeLauncher,
    fuumaShuriken,

    // Armor classes
    upper,
    middle,
    lower,
    upperMiddle,
    midleLower,
    upperLower,
    upperMiddleLower,
    armor,
    shield,
    garment,
    footgear,
    accessory,
    weapon,

    // Card classes
    headgearCard,
    armorCard,
    weaponCard,
    shieldCard,
    garmentCard,
    accessoryCard,
    footgearCard,

    // Ammunition classes
    arrow,
    throwingDagger,
    bullet,
    shell,
    grenade,
    shuriken,
    kunai,
    cannonBall,
    throwWeapon,

    // Other
    none;

    /**
     * Список всех названий классов итемов
     */

    private static transient Map<ItemClass, String> classNames = new HashMap<ItemClass, String> ();

    static
    {
        // Weapon classes
        classNames.put ( dagger, "Dagger" );
        classNames.put ( oneHandedSword, "One-handed Sword" );
        classNames.put ( twoHandedSword, "Two-handed Sword" );
        classNames.put ( oneHandedSpear, "One-handed Spear" );
        classNames.put ( twoHandedSpear, "Two-handed Spear" );
        classNames.put ( oneHandedAxe, "One-handed Axe" );
        classNames.put ( twoHandedAxe, "Two-handed Axe" );
        classNames.put ( mace, "Mace" );
        classNames.put ( oneHandedStaff, "One-handed Staff" );
        classNames.put ( twoHandedStaff, "Two-handed Staff" );
        classNames.put ( bow, "Bow" );
        classNames.put ( knuckle, "Knuckle" );
        classNames.put ( musicalInstrument, "Musical Instrument" );
        classNames.put ( whip, "Whip" );
        classNames.put ( book, "Book" );
        classNames.put ( katar, "Katar" );
        classNames.put ( revolver, "Revolver" );
        classNames.put ( rifle, "Rifle" );
        classNames.put ( gatlingGun, "Gatling Gun" );
        classNames.put ( shotgun, "Shotgun" );
        classNames.put ( grenadeLauncher, "Grenade Launcher" );
        classNames.put ( fuumaShuriken, "Fuuma Shuriken" );

        // Armor classes
        classNames.put ( upper, "Upper Headgear" );
        classNames.put ( middle, "Middle Headgear" );
        classNames.put ( lower, "Lower Headgear" );
        classNames.put ( upperMiddle, "Upper & Middle Headgear" );
        classNames.put ( midleLower, "Middle & Lower Headgear" );
        classNames.put ( upperLower, "Upper & Lower Headgear" );
        classNames.put ( upperMiddleLower, "Upper, Middle & Lower Headgear" );
        classNames.put ( armor, "Armor" );
        classNames.put ( shield, "Shield" );
        classNames.put ( garment, "Garment" );
        classNames.put ( footgear, "Footgear" );
        classNames.put ( accessory, "Accessory" );
        classNames.put ( weapon, "Weapon" );

        // Card classes
        classNames.put ( headgearCard, "Headgear Card" );
        classNames.put ( armorCard, "Armor Card" );
        classNames.put ( weaponCard, "Weapon Card" );
        classNames.put ( shieldCard, "Shield Card" );
        classNames.put ( garmentCard, "Garment Card" );
        classNames.put ( accessoryCard, "Accessory Card" );
        classNames.put ( footgearCard, "Footgear Card" );

        // Ammunition classes
        classNames.put ( arrow, "Arrow" );
        classNames.put ( throwingDagger, "Throwing dagger" );
        classNames.put ( bullet, "Bullet" );
        classNames.put ( shell, "Shell" );
        classNames.put ( grenade, "Grenade" );
        classNames.put ( shuriken, "Shuriken" );
        classNames.put ( kunai, "Kunai" );
        classNames.put ( cannonBall, "Cannon Ball" );
        classNames.put ( throwWeapon, "Throw Weapon" );

        // Other
        classNames.put ( none, "n/a" );
    }

    public String getClassName ()
    {
        return classNames.get ( this );
    }

    /**
     * Список всех классов оружий
     */

    private static final List<ItemClass> weaponClasses =
            Arrays.asList ( dagger, oneHandedSword, twoHandedSword, oneHandedSpear, twoHandedSpear,
                    oneHandedAxe, twoHandedAxe, mace, oneHandedStaff, twoHandedStaff, bow, knuckle,
                    musicalInstrument, whip, book, katar, revolver, rifle, gatlingGun, shotgun,
                    grenadeLauncher, fuumaShuriken );

    public static List<ItemClass> getWeaponClasses ()
    {
        return weaponClasses;
    }

    /**
     * Список всех классов шапок
     */

    private static final List<ItemClass> headgearClasses =
            Arrays.asList ( upper, middle, lower, upperMiddle, midleLower, upperLower,
                    upperMiddleLower );

    public static List<ItemClass> getHeadgearClasses ()
    {
        return headgearClasses;
    }

    /**
     * Получение класса итема по названию
     */

    public static ItemClass getItemClass ( String className )
    {
        className = className.trim ();
        for ( ItemClass key : classNames.keySet () )
        {
            if ( classNames.get ( key ).equals ( className ) )
            {
                return key;
            }
        }
        return ItemClass.none;
    }
}